import pymysql


def get_cur(db_name):
    """
    开启数据库并获得游标
    :param db_name:数据库名称
    :return: 返回数据库游标
    """
    conn = pymysql.connect(
        host='127.0.0.1',
        user='root',
        password='root',
        port=3306,
        db=db_name,
        charset='utf8'
    )
    return conn, conn.cursor()


def close_db(conn, cur):
    """
    关闭游标和数据
    :param conn: 数据连接
    :param cur: 游标
    :return: None
    """
    cur.close()
    conn.close()
    return None
